package tcp;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 封装一个专门做打印的类
 **/
public class Log {
    public static void println(Object o){
        Date date=new Date();
        DateFormat format=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
        String now=format.format(date);
        String name=Thread.currentThread().getName();//被哪个线程调用就会打印哪个线程的名字
        System.out.println(now+":"+name+":"+o.toString());
    }
    public static void print(Object o){
        Date date=new Date();
        DateFormat format=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
        String now=format.format(date);
        String name=Thread.currentThread().getName();
        System.out.print(now+":"+name+":"+o.toString());
    }
    public static void printlf(String fmt,Object... args){
        Date date=new Date();
        DateFormat format=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
        String now=format.format(date);
        String name=Thread.currentThread().getName();
        System.out.printf(now+":"+name+":"+fmt,args);
    }
}
